package com.integrance.budgetapp.dao.hibernate;

import java.util.List;

import com.integrance.budgetapp.dao.UserAccountDao;
import com.integrance.budgetapp.domain.UserAccount;

public class UserAccountDaoHibernateImpl extends GenericDaoHibernateImpl<UserAccount, Long>
		implements UserAccountDao {

	public UserAccountDaoHibernateImpl(Class<UserAccount> type) {
		super(type);		
	}
	
	public UserAccount getUserAccount(String userName) {
		UserAccount userAccount = null;
		
		List accounts = getHibernateTemplate().findByNamedParam(
				"from UserAccount ua where ua.name = :userName", "userName", userName);
		
		if (accounts != null && accounts.size() != 0) {
			userAccount = (UserAccount) accounts.get(0);
		} 
		
		return userAccount;
	}
	 
}
